/**
 * 
 */
package com.hospital.proxy;

import java.util.List;

import com.hospital.dao.IKeshiDao;
import com.hospital.dao.impl.KeshiDaoImpl;
import com.hospital.dbc.DatabaseConnection;
import com.hospital.vo.Keshi;

/**
 * @author Administrator
 *
 */
public class KeshiDaoProxy implements IKeshiDao {
	IKeshiDao dao = null;
	DatabaseConnection dbc = null;
	public KeshiDaoProxy() {
		try {
			this.dbc = new DatabaseConnection();
		} catch (Exception e) {
			e.printStackTrace();
		}
		this.dao = new KeshiDaoImpl(this.dbc.getConnection());
	}
	/* (non-Javadoc)
	 * @see com.hospital.dao.IKeshiDao#doCreate(com.hospital.vo.Keshi)
	 */
	@Override
	public boolean doCreate(Keshi keshi) throws Exception {
		boolean flag = false;
		try {
			flag = this.dao.doCreate(keshi);
		} catch (Exception e) {
			throw e;
		} finally {
			this.dbc.close();
		}
		return flag;
	}

	/* (non-Javadoc)
	 * @see com.hospital.dao.IKeshiDao#doUpdate(com.hospital.vo.Keshi)
	 */
	@Override
	public boolean doUpdate(Keshi keshi) throws Exception {
		boolean flag = false;
		try {
			flag = this.dao.doUpdate(keshi);
		} catch (Exception e) {
			throw e;
		} finally {
			this.dbc.close();
		}
		return flag;
	}

	/* (non-Javadoc)
	 * @see com.hospital.dao.IKeshiDao#doDel(int)
	 */
	@Override
	public boolean doDel(int kid) throws Exception {
		boolean flag = false;
		try {
			flag = this.dao.doDel(kid);
		} catch (Exception e) {
			throw e;
		} finally {
			this.dbc.close();
		}
		return flag;
	}
	@Override
	public List<Keshi> findAll() throws Exception {
		List<Keshi> list = null;
		try {
			list = this.dao.findAll();
		} catch (Exception e) {
			throw e;
		} finally {
			this.dbc.close();
		}
		return list;
	}
	@Override
	public Keshi findById(int kid) throws Exception {
		Keshi keshi = null;
		try {
			keshi = this.dao.findById(kid);
		} catch (Exception e) {
			throw e;
		} finally {
			this.dbc.close();
		}
		return keshi;
	}

}
